package com.gzx.plugin.tjzy.modular.sms.template.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzx.plugin.tjzy.modular.sms.template.bo.GzxSmsTemplateAddOrEditBo;
import com.gzx.plugin.tjzy.modular.sms.template.bo.GzxSmsTemplateQueryBo;
import com.gzx.plugin.tjzy.modular.sms.template.service.GzxSmsTemplateService;
import com.gzx.plugin.tjzy.modular.sms.template.vo.GzxSmsTemplateVo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;

import java.util.List;

/**
 * @author zjt
 * @description
 * @date 2025/3/6 18:40
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/tjzy/sms/template")
public class GzxSmsTemplateController {

    private final GzxSmsTemplateService smsTemplateService;

    @PostMapping("/pageList")
    public CommonResult<Page<GzxSmsTemplateVo>> pageList(@RequestBody GzxSmsTemplateQueryBo smsTemplateQueryBo) {
        return CommonResult.data(smsTemplateService.pageList(smsTemplateQueryBo));
    }

    @GetMapping("/list")
    public CommonResult<List<GzxSmsTemplateVo>> list() {
        return CommonResult.data(smsTemplateService.list());
    }

    @PostMapping("/addOrEdit")
    @CommonLog("短信模版新增")
    public CommonResult<Void> add(@RequestBody GzxSmsTemplateAddOrEditBo smsTemplateAddOrEditBo) {
        smsTemplateService.addOrEdit(smsTemplateAddOrEditBo);
        return CommonResult.ok();
    }

    @GetMapping("/del/{id}")
    @CommonLog("短信模版删除")
    public CommonResult<Void> delete(@PathVariable Long id) {
        smsTemplateService.delete(id);
        return CommonResult.ok();
    }
}
